<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>demo1</title>

</head>
<body>
<p>替换"microsoft"为"W3cSchool"</p>
<!--<button onclick="myFunction()">点我 </button>-->
<input type="text" id="age"/>
<button onclick="myFunction()">判断是否大于18岁</button>
<p id="result"></p>
<p id="demo">Please visit Microsoft! </p>
<script>
	function myFunction()
	{
//		var str=document.getElementById("demo").innerHTML;
//		var txt=str.replace("Microsoft","W3cSchool");
//		document.getElementById("demo").innerHTML=txt;
		var age = document.getElementById("age").value;
//		alert(age);
		if (age>=18) {

			document.getElementById("result").innerHTML = "您已经成年了";
			document.getElementById("result").style.color = "yellow";
			document.getElementById("result").style.background = "black";

		}else {
			document.getElementById("result").innerHTML = "你还未成年";
			document.getElementById("result").style.color = "red";
			document.getElementById("result").style.background = "black";

		}

	}

</script>

</body>
</html>
